package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AddNursingLevelDto;
import com.zzyl.dto.NursingSearchLevelDto;
import com.zzyl.dto.UpdateNursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingSearchLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Insight
 * @Description: TODO
 * @Date: 2024/6/7 8:38
 * @Version: 1.0
 */
@RestController
@RequestMapping("/nursingLevel")
public class NursingLevelController {
    @Autowired
    NursingLevelService nursingLevelService;

    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingSearchLevelVo>> selectAll(NursingSearchLevelDto dto) {
        PageResponse<NursingSearchLevelVo> vo = nursingLevelService.selectAll(dto);
        return ResponseResult.success(vo);
    }

    @PostMapping("/insert")
    public ResponseResult add(AddNursingLevelDto dto) {
        nursingLevelService.add(dto);
        return ResponseResult.success();
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingSearchLevelVo> selectById(@PathVariable("id") Long id) {
        NursingSearchLevelVo vo = nursingLevelService.selectById(id);
        return ResponseResult.success(vo);
    }

    @PutMapping("/update")
    public ResponseResult update(UpdateNursingLevelDto dto) {
        nursingLevelService.update(dto);
        return ResponseResult.success();
    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Long id) {
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult setStatus(@PathVariable("id") long id, @PathVariable("status") Integer status) {
        nursingLevelService.setStatus(id, status);
        return ResponseResult.success();
    }
}
